package com.javaclimb.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.javaclimb.mappers.ManagerMapper;
import com.javaclimb.pojo.Manager;
import com.javaclimb.pojo.User;
import com.javaclimb.service.ManagerService;
import com.javaclimb.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ManagerServiceImp implements ManagerService {
    @Autowired
    private ManagerMapper managerMapper;

    @Override
    public PageBean page(Integer page, Integer pageSize, Integer id, String name,Integer sex, Integer age) {
        //1.设置分页参数
        PageHelper.startPage(page,pageSize);
        //2.执行查询
        List<Manager> managerList = managerMapper.list(id,name,sex,age);//传递条件查询参数
        Page<Manager> p = (Page<Manager>) managerList;
        //3.封装bean对象
        PageBean pB = new PageBean(p.getTotal(), p.getResult());
        return pB;
    }

    @Override
    public void delete(List<Integer> ids) {
        managerMapper.delete(ids);
    }

    @Override
    public void update(Manager manaegr) {
        managerMapper.updateUserInfo(manaegr);
    }
}
